//
//  StriveViewController.m
//  HaoHaiSpell
//
//  Created by haohai on 16/6/17.
//  Copyright © 2016年 海城. All rights reserved.
//

#import "StriveViewController.h"
#import "StriveCell.h"
@interface StriveViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UICollectionView *striveCollectionView;
@property (weak, nonatomic) IBOutlet UIView *markView;
@property (weak, nonatomic) IBOutlet UIButton *immediatelyBtn;
@property (weak, nonatomic) IBOutlet UIButton *totalRequestBtn;
@property (weak, nonatomic) IBOutlet UILabel *markLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *changeMarks;
@property (nonatomic,strong) NSMutableArray *bannersArray; //轮播图数组
@property (nonatomic,strong) NSMutableDictionary *parameter; //网络请求参数
@property (nonatomic,strong) NSMutableArray *allDataArr;//数据源
@property (nonatomic,strong) UIButton *selebtn;//选中按钮


@end

@implementation StriveViewController
#pragma mark - 懒加载
- (NSMutableArray *)bannersArray{
    
    if (!_bannersArray) {
        UIImage *image = [UIImage imageNamed:@"contentimg.jpg"];
<<<<<<< HEAD
        _bannersArray=[NSMutableArray arrayWithArray:@[image]];
=======
        _bannersArray=[NSMutableArray arrayWithArray:@[image,image,image]];
>>>>>>> 5bee59541ff07dbcbaa6fe419e6df24b39c5e23d
    }
    return _bannersArray;
}

- (NSMutableDictionary*)parameter{
    
    if (!_parameter) {
        _parameter = [NSMutableDictionary dictionaryWithDictionary:@{@"page":@1,@"type":@3}];
    }
    return _parameter;
}

-(NSMutableArray *)allDataArr{

    if (!_allDataArr) {
        _allDataArr=[NSMutableArray new];
    }

    return _allDataArr;
}



#pragma mark - 自定义
<<<<<<< HEAD
=======

>>>>>>> 5bee59541ff07dbcbaa6fe419e6df24b39c5e23d
-(void)selBtnAction:(UIButton *)button{
    
    //设置偏移及字体颜色
    [self.selebtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.selebtn .transform = CGAffineTransformIdentity;
    [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [UIView animateWithDuration:0.3
                     animations:^{
                         
                         CGPoint point = self.markLabel.center;
                         point.x = button.center.x;
                         self.markLabel.center = point;
                         
                         [self.markView layoutIfNeeded];
                     }];
    self.selebtn = button;
}


- (IBAction)ImmediatelyAction:(UIButton *)sender {
    
    [self selBtnAction:sender];
    NSLog(@"立即揭晓");
}

- (IBAction)totalRequestAction:(UIButton *)sender {
    
    [self selBtnAction:sender];
    NSLog(@"总需人次");
}





#pragma mark - 视图生命周期
- (void)viewDidLoad {
    [super viewDidLoad];
    
    //collectionView的设置
    UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout *)self.striveCollectionView.collectionViewLayout;
<<<<<<< HEAD
    [flowLayout setItemSize:CGSizeMake((kWidth - 30) / 2.0, 167)];
=======
    [flowLayout setItemSize:CGSizeMake((kWidth - 30) / 2.0, 240)];
>>>>>>> 5bee59541ff07dbcbaa6fe419e6df24b39c5e23d
    [flowLayout setMinimumInteritemSpacing:10];
    [flowLayout setMinimumLineSpacing:10];
    [flowLayout setSectionInset:UIEdgeInsetsMake(0, 10, 0, 10)];
    //没有头视图，只能设置偏移量
<<<<<<< HEAD
    self.striveCollectionView.contentInset = UIEdgeInsetsMake(167, 0, 0, 0);
=======
    self.striveCollectionView.contentInset = UIEdgeInsetsMake(214, 0, 0, 0);
>>>>>>> 5bee59541ff07dbcbaa6fe419e6df24b39c5e23d
    // 添加轮播图
    [self addCarouselImage];
    
    self.striveCollectionView.backgroundColor = HWColor(241, 241, 241);
    // 注册单元格
    [self.striveCollectionView registerNib:[UINib nibWithNibName:@"StriveCell" bundle:nil] forCellWithReuseIdentifier:@"striveCell"];
    
    // Do any additional setup after loading the view.
}


//添加轮播图
- (void)addCarouselImage{
    
<<<<<<< HEAD
//    WFCarousel *carrouel = [[WFCarousel alloc]initWithFrame:CGRectMake(0, 64, kWidth, (kHeight -64) / 3) pictureArray:self.bannersArray];
//     [self.view addSubview:carrouel];
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 64, kWidth, (kHeight -64) / 4)];
    imageView.image = self.bannersArray[0];
    [self.view addSubview:imageView];
 }
=======
    WFCarousel *carrouel = [[WFCarousel alloc]initWithFrame:CGRectMake(0, 64, kWidth, 234) pictureArray:self.bannersArray];
     [self.view addSubview:carrouel];
}
>>>>>>> 5bee59541ff07dbcbaa6fe419e6df24b39c5e23d







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark - UICollectionViewDelegate,UICollectionViewDataSource
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

    return 10;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    StriveCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"striveCell" forIndexPath:indexPath];
    return cell;
}






@end
